package org.yangspring.samples.mvc.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.yangspring.samples.mvc.dao.CompanyDAO;
import org.yangspring.samples.mvc.domain.Company;

import java.util.List;

/**
 * Created by whyang on 2017/06/19.
 */

@Service
public class CompanyServiceImpl implements CompanyService {

    @Autowired
    private CompanyDAO companyDao;

    /*public void setCompanyDao(CompanyDAO dao){
        this.companyDao = dao;
    }*/

    @Transactional
    public void addCompany(Company company){
        this.companyDao.addCompany(company);
    }

    @Transactional
    public void updateCompany(Company company){
        this.companyDao.updateCompany(company);
    }

    @Transactional
    public List<Company> listCompany(){
        return this.companyDao.listCompany();
    }

    @Transactional
    public Company getCompanyById(int id){
        return this.companyDao.getCompanyById(id);
    }

    @Transactional
    public void removeCompany(int id){
        this.companyDao.removeCompany(id);
    }

}
